#!/usr/bin/env node

const args = require("args");
const path = require("path");
const process = require("process");
const fs = require("fs");
const getUploadPaths = require("./get_upload_paths.js").getUploadPaths;
const mongoConnect = require("../lib/mongoose_connect");
const lib = require("../lib");
let cwd = process.cwd();
console.log("cwd :", cwd);
let flags = args.parse(process.argv);
let sub = args.sub;

mongoConnect.then(async _connected=>{
  let avai_paths = await getUploadPaths(cwd,sub);
  debugger
  for(let ap of avai_paths){
    console.log(ap.full_path);
    let o_process = await lib.insert2Mongodb(ap.full_path);
  }
  process.exit(0);
})

